﻿namespace Raven
{
    public abstract class TriggerLimitedLifeTime<entity_type> : Trigger<entity_type>
    {
        protected Fix _lifeTIme;

        protected TriggerLimitedLifeTime(EntityType type, Fix lifeTime) : base(type)
        {
            _lifeTIme = lifeTime;
        }

        public override void Update()
        {
            //if the lifetime counter expires set this trigger to be removed from
            //the game
            _lifeTIme = _lifeTIme - 1 / Constants.FrameRate;
            if (_lifeTIme <= 0)
            {
                SetToBeRemovedFromGame();
            }
        }
    }
}